package com.itheima.reggie.common;

import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 刘付磊
 * @date 2021/10/18 0018
 */
@ControllerAdvice(annotations = {Service.class})
@ResponseBody
public class GlobalExceptionHandler {

    @ExceptionHandler(CustomException.class)
    public R<String> exceptionHandler(CustomException Ex){
        return R.success(Ex.getMessage());
    }
}
